package org.example.controller;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import org.example.common.ResponseResult;
import org.example.pojo.GoodDto;
import org.example.pojo.Goods;
import org.example.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("goods")
@Api(tags = "关于good的controller",description = "该controller的描述")
public class GoodController {
    @Autowired
    private GoodsService goodsService;

    @PostMapping("/delGood")
    public ResponseResult delGood(Integer id){
        return goodsService.delGood(id);
    }

    @PostMapping("/goodList")
    public ResponseResult goodList(@RequestBody GoodDto dto){

        return goodsService.goodList(dto);
    }

    @PostMapping("updateGood")
    public ResponseResult updateGood(@RequestBody Goods goods){
        return goodsService.updateGood(goods);
    }

    @PostMapping("getOne")
    public ResponseResult getOne(Integer id){
        return goodsService.getOne(id);
    }

    /**
     * 添加商品
     * @param goods
     * @return
     */
    @PostMapping("addGood")
    @ApiOperation("该接口的功能描述-分页查询")
    public ResponseResult addGood(@RequestBody Goods goods){
        return goodsService.addGood(goods);
    }

    /**
     * 商品进行审核  审核通过添加
     * @param id
     * @return
     */
    @PostMapping("autoGood/{id}")
    public ResponseResult autoGood(@PathVariable("id") Integer id){
        return goodsService.autoGood(id);
    }

    /**
     * 对下架商品进行上架处理
     * @param id
     * @return
     */
    @PostMapping("upGood/{id}")
    public ResponseResult upGood(@PathVariable("id")Integer id){
        return goodsService.upGood(id);
    }

    /**
     * 对上架商品进行下架处理
     * @param id
     * @return
     */
    @PostMapping("downGood/{id}")
    public ResponseResult downGood(@PathVariable("id")Integer id){
        return goodsService.downGood(id);
    }

    /***
     * 完成对es数据的初始化
     * @return
     */
    @PostMapping("enInit")
    public ResponseResult enInit(){
        return goodsService.enInit();
    }

    /**
     * 对用户的关键词进行es中的搜索
     * @param dto
     * @return
     */
    @PostMapping("/searchKeyWord")
    public ResponseResult searchKeyWord(@RequestBody GoodDto dto){
        return goodsService.searchKeyWord(dto);
    }

}
